define(['jquery','jqueryUI','Widget'],function($,$UI,widget){
	function Window(){
		this.CFG={
			content:'Hello World!',
			width:500,
			height:300,
			title:'系统消息',
			hasCloseBtn:false,
			handler4AlertBtn:null,
			handler4CloseBtn:null,
			okContent:'确定',
			hasMask:true,
			isDraggable:true,
		};
	}
	Window.prototype=$.extend({},new widget.Widget(),{
			renderUI:function(){
					var temple='<div class="window_boundingBox">'+
						'<div class="window_boundingHeader">'+this.CFG.title+'</div>'+
						'<div class="window_boundingContent">'+this.CFG.content+'</div>'+
						'<div class="window_boundingButton"><input type="button" value="'+this.CFG.okContent+'" class="ok"></input></div>'+
					'</div>';
					var boundingBox=$(temple);
					var mask=null;
					if(this.CFG.hasMask){
						mask=$('<div class="window_boundingMask"></div>')
						mask.appendTo('body');
					}
					if(this.CFG.hasCloseBtn){
						var btn=$('<input type="button" value="X" class="close"></input>');
						boundingBox.append(btn);
					}
					this.boundingBox=boundingBox;
			},
			bindUI:function(){
				var that=this;
				$('.ok').on("click",function(){
					that.fire('alert');
					that.destory();
				});
				$('.close').on("click",function(){
					that.fire('close');
					that.destory();
				});
				if(that.CFG.isDraggable){
					if(that.CFG.dragHandle){
						that.boundingBox.draggable({handle:that.CFG.dragHandle});
					}else{
						that.boundingBox.draggable();	
					}
					
				}
			},
			syncUI:function(){
				this.boundingBox.css({
					width:this.CFG.width+'px',
					height:this.CFG.height+'px',
					left:(this.CFG.x || (window.innerWidth-this.CFG.width)/2)+'px',
					top:(this.CFG.y|| (window.innerHeight-this.CFG.height)/2)+'px',
					margin:'-'+this.CFG.width/2+'px'
				});
				if(this.CFG.skinClassName){
					this.boundingBox.addClass(this.CFG.skinClassName);
				}
			},
			destructor:function(){
				if(this.CFG.hasMask){
					$(".window_boundingMask").remove();
				}
			},
			alert:function(CFG){
				$.extend(this.CFG,CFG);
				this.render();
				return this;
			}
		});
	return {
		Window:Window
	}
});